<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
</head>
<body>
<form action="/" method="POST" onsubmit="return register()">
    <label>用户名：</label><input id="username" type="text" name="username"><br/>
    <label>密码：</label><input type="password"><br/>
    <label>性别：</label>
    男 <input type="radio" name="sex" checked="checked" value="男">
    女<input type="radio" name="sex" value="女"><br/>
    <label>学历：
        幼儿园<input type="radio" name="degree" checked="checked" value="0">
        小学<input type="radio" name="degree" value="1">
        初中<input type="radio" name="degree" value="2">
        高中<input type="radio" name="degree" value="3">
        大专<input type="radio" name="degree" value="4">
        本科<input type="radio" name="degree" value="5">
        <br/>
        <label>自我介绍：</label>
        <textarea id="info" cols="100" rows="10"></textarea>
        <br/>
        <input type="submit" value="注册">
</form>
</body>
<script>
    /**
     * 检查用户名
     * @param username
     */
    function checkUsername(username) {
        if (username != "admin") {
            return false;
        }
        return true;
    }

    /**
     * 提交
     */
    function register() {
        var username = document.getElementById("username").value;
        var info = document.getElementById("info").value;

        if (!checkUsername(username)) {
            alert("用户名错误！");
        } else {
            alert(info)
        }

        // 阻止表单提交
        return false;
    }
</script>
</html>